//
//  EmojiMemoryGame.swift
//  Memorize
//
//  Created by 姬向阳 on 2020/5/31.
//  Copyright © 2020 SUNNYJ. All rights reserved.
//

import SwiftUI

class EmojiMemoryGame: ObservableObject {
    @Published private var emojiMemoryGame: MemoryGame<String> = EmojiMemoryGame.creatMemoryGame()
    
    private static func creatMemoryGame() -> MemoryGame<String> {
        let emojis: Array<String> = ["👻","🎃","🕷"]
        return MemoryGame<String>(numberOfPairs: emojis.count) { (pairIndex) -> String in
            return emojis[pairIndex]
        }
    }
    
    // MARK:- Access to the Model
    
    var cards: Array<MemoryGame<String>.Card> {
        emojiMemoryGame.cards
    }
    
    // MARK:- Intent(s)
    
    func chooseCard(card: MemoryGame<String>.Card) {
        emojiMemoryGame.chooseCard(card: card)
    }
    
    func resetGame() {
        emojiMemoryGame = EmojiMemoryGame.creatMemoryGame()
    }
}
